import axios from "axios";

export default {
  namespaced: true,
  state: {
    isEsist: ""
  },
  getter:{

  },
  mutations: {
  },
  actions: {
    addNewManagerAsync(state, payload){
      console.log(payload);
      axios.post("/users/addNewAccount", payload).then(res => {
        if(res.data){
          alert('申请已提交!');
        }
      })
    },
    usernameIsExistAsync(state, payload){
      console.log(payload);
      axios.get("/api/users/usernameIsExist", {params: {username: payload.value}}).then(res => {
        console.log(res.data);
        if(res.data){
          payload.callback(new Error('用户名已存在'));
        }
        payload.callback();
      })
    }
  },
  modules: {
  }
}
